﻿<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<title>Object Copy Tests</title>

		<link href="../Common/Styles/qunit.css" type="text/css" rel="stylesheet" />

		<script src="../Common/Scripts/JQuery/jquery-1.3.2.js" type="text/javascript"></script>
		<script src="../Common/Scripts/QUnit/qunit.js" type="text/javascript"></script>
		<script src="../Common/Scripts/Microsoft/MicrosoftAjax.js" type="text/javascript"></script>
		<script src="../Common/Scripts/ExoWeb/exoweb.js" type="text/javascript"></script>
		<script src="../Common/Scripts/QUnit/qunit.ext.js" type="text/javascript"></script>

		<script type="text/javascript">
			test("Simple Copy of Object", function() {
				var obj = { "a": 1, "b": 2 };
				var copy = Object.copy(obj);

				equals(obj.a, copy.a, "Value type properties of copy should equal original object.");
				equals(obj.b, copy.b, "Value type properties of copy should equal original object.");
				ok(obj !== copy, "Copy should not equal the original object.");
			});

			test("Copy of Object with Object properties", function() {
				var reference = { "z": 1000 };

				var obj = { "a": 1, "ref": reference };
				var copy = Object.copy(obj);

				equals(obj.a, copy.a, "Value type properties of copy should equal original object.");
				equals(obj.ref, copy.ref, "Object type properties of copy should equal original object.");
				equals(obj.ref.z, copy.ref.z, "Value type properties of copy (of object property) should equal original object.");
				ok(obj !== copy, "Copy should not equal the original object.");

				var copy2 = Object.copy(obj, { copyChildren: true });
				ok(obj.ref !== copy2.ref, "Object type properties of copy should NOT equal original object when \"copyChildren\" setting is true.");
			});

			test("Copy of Array", function() {
				var arr = [1, 2, 3];
				var copy = Object.copy(arr);

				same(arr, copy, "Copy of array should contain the same elements as the original.");
			});
		</script>
	</head>
	<body>
		<!-- QUnit Display -->
		<h1 id="qunit-header">Test Results:</h1>
		<h2 id="qunit-banner"></h2>
		<h2 id="qunit-userAgent"></h2>
		<ol id="qunit-tests"></ol>
	</body>
</html>
